package com.digitalart.futbol.service.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.digitalart.futbol.hibernate.ejb.Distrito;
import com.digitalart.futbol.hibernate.service.DistritoService;

@Controller
@RequestMapping(value="/distrito")
public class DistritoController {
	
	@Autowired
	private DistritoService distritoServ;
	
	@RequestMapping(value = "/getById/{id}", method = RequestMethod.GET)
	public @ResponseBody Distrito getById(@PathVariable("id") int id) {
	
		Distrito distrito = distritoServ.retriveDistrito(id);
		
		return distrito;
	}
	
	@RequestMapping(value = "/getAll", method = RequestMethod.GET)
	public @ResponseBody List<Distrito> getAll() {
	
		List<Distrito> distritos = distritoServ.findAll();
		
		return distritos;
	}
}
